#pragma once

#include "xml_helper.hpp"

#include "topcvt_buffer.hpp"
#include "topcvt_unpack.hpp"

namespace topcvt
{
	class XmlUnpack : public UnpackImp
	{
	protected:
		pugi::xml_document m_doc;
		string m_encoding;
		std::stack<pugi::xml_node*> m_xmlStack;
	public:
		XmlUnpack(ByteBuffer& message);
		virtual ~XmlUnpack() {};

		virtual PolicyContext& unpackPolicy(PolicyContext& ctx, PolicyCfg& cfg) override ;
		virtual string unpackField(pugi::xml_node& node, FieldCfg& cfg, PolicyContext& ctx) override;
		virtual void unpackStruct(pugi::xml_node& node, StructCfg& cfg, PolicyContext& ctx) override;
		virtual void unpackLoop(pugi::xml_node& node, LoopCfg& cfg, PolicyContext& ctx) override;
	};
};